/*
 * Copyright (c) 2024 OpenValley(ShenZhen) Digital Industry Development Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef ACCESSORYKIT_H
#define ACCESSORYKIT_H

#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif
#endif

/**
 * @brief Enumerates the status of the AccessoryKit service.
 */
typedef enum {
    /** data empty, do not received data. */
    ACCEKIT_DATA_EMPTY = -2,
    /** parameter error. */
    ACCEKIT_PARAM_ERROR = -1,
    /** default, disconnected phone. */
    ACCEKIT_DISCONNECTED = 0,
    /** connected phone. */
    ACCEKIT_CONNECTED = 1,
    /** received data. */
    ACCEKIT_RECEIVE_DATA = 2,
}ACCEKIT_STATUS;

/**         
 * @brief       Get the status of the AccessoryKit service.        
 * @param[in]   none.
 * @return      ret.       -  ACCEKIT_STATUS
 */
int AcceKitStatus(void);

/**
 * @brief       Initialize AcceKit capability，such as BLE.
 * @param[in]   none.
 * @return      none.
 */
void AcceKitInit(void);

/**
 * @brief       Register Irq function.
 * @param[in]   none.
 * @return      none.
 */
void AcceKitIrqInit(void);

/**
 * @brief       Send data to a connected phone using AcceKitWriteData.
 *              Please ensure that the device is connected before use. 
 * @param[in]   data         - Pointer point to application data buffer.
 * @param[in]   len          - the length of data.
 * @return      none.
 */
void AcceKitSendData(unsigned char *data, int len);

/**
 * @brief       Get data from a connected device.
 *              Please ensure that the device is connected before use. 
 *              The maximum length of a single transmission of data is x_BUFF_LEN=20 bytes.
 *              After obtaining data, the buffer will be automatically cleared
 * @param[in]   str.       -  Pointer point to application data buffer.   
 * @return      ret.       -  ACCEKIT_PARAM_ERROR: input param error.
 *                            ACCEKIT_DATA_EMPTY: get data buff is empty.
 *                            ACCEKIT_RECEIVE_DATA: get data success.
 */
int AcceKitGetData(char *str);

/**  Todo
 * @brief       Set the device name(same as BLE name).
 *              Please ensure that the parameters of the mian and secondary services are different..
 * @param[in]   Name.       - OBU device name.   
 * @param[in]   len.        - the length of data, Maximum 12 bytes.   
 * @return      none. 
 */
void AcceKitSetDeviceName(char *Name, int len);

// Todo 
/**
 * @brief       Set main service parameters.
 *              Please ensure that the parameters of the mian and secondary services are different. 
 * @param[in]   Name.       - Main service name.   
 * @param[in]   UUID.       - Main service UUID. 
 * @return      none. 
 */
void AcceKitSetMainServer(char *Name, unsigned int UUID);

/** Todo
 * @brief       Set second service parameters.
 *              Please ensure that the parameters of the mian and secondary services are different.
 * @param[in]   Name.       - Second Service Name.   
 * @param[in]   UUID.       - Second Service UUID. 
 * @return      none. 
 */
void AcceKitSetSecondServer(char *Name, unsigned int UUID);

#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif

#endif //  ACCESSORYKIT_H